package com.edu.exam.enums.examination;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 事件来源枚举
 */
@Getter
@AllArgsConstructor
public enum EventSource {
    USER("USER", "用户"),
    SYSTEM("SYSTEM", "系统"),
    AUTOMATION("AUTOMATION", "自动化"),
    ADMIN("ADMIN", "管理员"),
    INSTRUCTOR("INSTRUCTOR", "教师"),
    PROCTOR("PROCTOR", "监考员"),
    MONITOR("MONITOR", "监控"),
    EXTERNAL("EXTERNAL", "外部"),
    API("API", "接口"),
    TIMER("TIMER", "定时器");

    private final String code;
    private final String description;

    public static EventSource fromCode(String code) {
        for (EventSource source : values()) {
            if (source.getCode().equals(code)) {
                return source;
            }
        }
        return SYSTEM; // 默认返回系统
    }
}